/* -*- mode: c++ -*-
** button.h
** 
** 
** 
*/

#ifndef   	BUTTON_H_
# define   	BUTTON_H_

#include <systemc.h>

#include "if.h"
#include "simple_bus.h"


struct buttonPacket 
{
	unsigned int size;
	unsigned int id;
	unsigned int pushed; // 1 is pushed, 0 is released
};

//  Our beloved button class (changes are required)
class Button : public sc_module,
							 public buttonIf
							 
{
 public:
	sc_port<buttonAdapterIf> busp;
	bool light;
	
	Button (sc_module_name, int);
	virtual void switchLight(bool b);
	virtual void main();
	sc_signal<bool> PUSH;
	
	
 private:
	int number;
	
};

// The Adapters class
class buttonAdapter: public sc_module,
		     public buttonAdapterIf
{
private:
  int currentButton;
  int Address;
  simple_bus_status status;
	struct buttonPacket dataPacket;
  
public:
  
  sc_port<buttonIf, 0> buttonp;
  sc_port<simple_bus_blocking_if> busp;
  
  buttonAdapter (sc_module_name name, int unique);
  void main(void);
  virtual void buttonPushed(int buttonAddress);
  virtual void send(struct buttonPacket* dataPacket);
  virtual void send_release_packet(struct buttonPacket* dataPacket, unsigned int freeloc);

};

#endif 	    /* !BUTTON_H_ */
